package com.itfenghuang.day06;

import java.util.TreeSet;

public class A00 {
    public static void main(String[] args) {

        TreeSet<Anm> set = new TreeSet<>();
        Anm anm1 = new Anm(18,"小小");
        Anm anm2 = new Anm(40,"爆爆");
        Anm anm3 = new Anm(22,"妹妹");
        set.add(anm1);
        set.add(anm2);
        set.add(anm3);
        System.out.println(set);
    }
}

class Anm implements  Comparable<Anm>{
    private int age;
    private String name;

    @Override
    public String toString() {
        return "Anm{" +
                "age=" + age +
                ", name='" + name + '\'' +
                '}';
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Anm() {
    }

    public Anm(int age, String name) {
        this.age = age;
        this.name = name;
    }

    @Override
    public int compareTo(Anm o) {
        int i = this.age - o.age;
        return -1;//   返回 0 去重  返回 1 按顺序打印
    }
}